package com.creawor.hz_market.resource.chanpingbao_resource;

import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;

import com.creawor.hz_market.servlet.LoadMapInfoAjax;
import com.creawor.imei.base.AbsQueryMap;

public class ChanpingbaoResource_QueryMap extends AbsQueryMap {
	private static final Logger logger = Logger.getLogger(LoadMapInfoAjax.class);
public ChanpingbaoResource_QueryMap() throws HibernateException {
	this.initSession();
}

public Iterator findAll() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from ChanpingbaoResource").next()).intValue();
	String querystr = "from ChanpingbaoResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.iterate();
}
public List findAllList() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from ChanpingbaoResource").next()).intValue();
	String querystr = "from ChanpingbaoResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}
public List findAllByCounty(String county) throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from ChanpingbaoResource where county ='"+county+"'").next()).intValue();
	String querystr = "from ChanpingbaoResource as t where t.county ='"+county+"'";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}

public ChanpingbaoResource_Form getByID(String ID) throws HibernateException {
	ChanpingbaoResource_Form  vo = null;

//System.out.println("\nt_group_QueryMap getByID:"+ID);
logger.debug("\nChanpingbaoResource_QueryMap getByID:"+ID);

	this.session.clear();
	try {
		vo =new ChanpingbaoResource_Form();
		ChanpingbaoResource po=(ChanpingbaoResource) this.session.load(ChanpingbaoResource.class, new Integer(ID));

try{
  vo.setId(String.valueOf(po.getId()));
}catch (Exception e) {
	    e.printStackTrace();
}
vo.setCompany(po.getCompany());
vo.setChanpingbao(po.getChanpingbao());
try{
	  vo.setPrice(String.valueOf(po.getPrice()));
	}catch (Exception e) {
		    e.printStackTrace();
	}
try{
	  vo.setNeirong(String.valueOf(po.getNeirong()));
	}catch (Exception e) {
		    e.printStackTrace();
	}
try{
	    vo.setUpdatedDay(com.creawor.km.util.DateUtil.getStr(po.getUpdatedDay(),"yyyy-MM-dd"));
	    vo.setInsertDay(com.creawor.km.util.DateUtil.getStr(po.getInsertDay(),"yyyy-MM-dd"));
	  }catch (Exception e) {
		    e.printStackTrace();
	  }



	} catch (HibernateException e) {
		
		logger.debug("\nERROR in getByID @ydproductresource:" + e);
	}
	return vo;
}	

}
//����������



